﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using huaguwang;

namespace huaguwang
{
    public class D_T_SecurCompany_Exp : D_T_SecurCompany
    {
        /// <summary>
        /// 分页获取数据量
        /// </summary>
        /// <returns></returns>
        public int GetPageCount(string title)
        {
            string strSQL = ExpandMSSQL.GetPageSQL(
                "T_SecurCompany ",
                "flag=1 and SecurCompany like '%'+@SecurCompany+'%'");
            SqlParameter parm = new SqlParameter("SecurCompany", SqlDbType.NVarChar, 100);
            parm.Value = title;
            var PageCount = MSSQLHelper.SQLConType.C1.Exp_GetSingle(strSQL, parm);
            return PageCount.Exp_IntTryParse();
        }

         /// <summary>
        /// 分页获取数据信息
        /// </summary>
        /// <param name="Begin">起始目录</param>
        /// <param name="Size">每页显示的数量</param>
        /// <returns></returns>
        public List<M_T_SecurCompany> GetPageList(int Begin, int Size, string title)
        {
                string strSQL = ExpandMSSQL.GetPageSQL(
                Begin,
                Size,
                "id,SecurCompany,Explain,AddDate,Contact,Commission",
                "T_SecurCompany",
                "id",
                "flag=1 and SecurCompany like '%'+@SecurCompany+'%'",
                "AddDate desc");
                SqlParameter parm = new SqlParameter("@SecurCompany", SqlDbType.NVarChar, 100);
                parm.Value = title;
                var List = MSSQLHelper.SQLConType.C1.Exp_GetList(strSQL,
                DR => new M_T_SecurCompany()
                {
                    id=DR["id"].Exp_IntTryParse(),
                    SecurCompany = DR["SecurCompany"].Exp_Trim(),
                    Explain = DR["Explain"].Exp_Trim().Exp_RegexHTML().Exp_SubStringByLength(52,"......"),
                    AddDate  = DR["AddDate"].Exp_DateTimeTryParse().Exp_GetString(ExpandDateTime.DateFormType.CnDate).Exp_DateTimeTryParse(),
                    Contact  =DR["Contact"].Exp_Trim(),
                    Commission  =DR["Commission"].Exp_IntTryParse()                         
                }, parm);
                return List;
        }
    }
}
